import { validateip } from '@/util/validate'
import { rule } from "@/util/validateRules";
//验证ip地址
const validateIp = (rule, value, callback) => {
  if (validateip(value)[0]) {
    callback(new Error(validateip(value)[1]))
  } else {
    callback()
  }
}
const portRule = (rule, value, callback) => {
  if (value > 65535){
    callback(new Error('最大值不得超过65535'))
  } else {
    callback()
  }
}
//^[1-9]\d*|0$
const  integerRule = (rule, value, callback) => {
  let reg = /^[1-9]\d*|0$/
  if (value && (!(reg).test(value))) {
    callback(new Error('只允许输入非负整数'))
  } else {
    callback()
  }
}
/** 线程池配置 **/
const threadPool = {
  title: '线程池配置',
  list: [
    {
      label: '最大线程数',
      value: '50',
      prop: 'maxSize',
      type: 'number',
      rules:[
        {required: true, message: '请输入最大线程数',  trigger: 'blur'},
        { validator: rule.validatorNumber, trigger: 'blur'}
      ]
    },
    {
      label: '核心线程数',
      value: '40',
      prop: 'coreSize',
      type: 'number',
      rules: [
        {required: true, message: '请输入核心线程数',  trigger: 'blur'},
        { validator: rule.validatorNumber, trigger: 'blur'}
      ]
    },
    {
      label: '缓冲队列大小',
      value: '5',
      prop: 'capacity',
      type: 'number',
      rules: [
        {required: true, message: '请输入缓冲队列大小',  trigger: 'blur'},
        { validator: rule.validatorNumber, trigger: 'blur'}
      ]
    },
    {
      label: '空闲线程存活时间',
      value: '5',
      prop: 'aliveTime',
      type: 'number',
      rules: [
        {required: true, message: '请输入空闲线程存活时间',  trigger: 'blur'},
        { validator: rule.validatorNumber, trigger: 'blur'}
      ]
    },
  ],
}


/** 配置第三方插件：除去webService设备，其他接出设备都需填写该项 ,TongLinkQ接入需填写**/
const thirdPlu = {
  title: '配置第三方插件',
  list: [
    {
      label: '插件类',
      value: '',
      prop: 'exterClass',
      type: 'input',
      maxlength: 200,
    },
    {
      label: '报文与通讯函数',
      value: '',
      prop: 'externPackAndSend',
      type: 'input',
      maxlength: 200,
    },
    {
      label: '组包函数',
      value: '',
      prop: 'externPack',
      type: 'input',
      maxlength: 200,
    },
    {
      label: '解包函数',
      value: '',
      prop: 'externUnpack',
      type: 'input',
      maxlength: 200,
    },
    {
      label: '通讯函数',
      value: '',
      prop: 'externSend',
      type: 'input',
      maxlength: 200,
    },
    {
      label: '组包前处理',
      value: '',
      prop: 'beforePack',
      type: 'input',
      maxlength: 200,
    },
    {
      label: '发送前请求处理',
      value: '',
      prop: 'beforeSend',
      type: 'input',
      maxlength: 200,
    },
    {
      label: '解包前处理',
      value: '',
      prop: 'beforeUnpack',
      type: 'input',
      maxlength: 200,
    },
    {
      label: '解包后处理',
      value: '',
      prop: 'beforeReturn',
      type: 'input',
      maxlength: 200,
    },
  ]
}


let formData = {
  IN: {
    tcp: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '连接类型',
            value: 'short',
            prop: 'connetionType',
            type: 'select',
            options: 'connect_type',
            rules: [
              {required: true, message: '请选择连接类型', trigger: 'change'}
            ]
          },
          {
            label: 'ip地址',
            value: '',
            prop: 'ip',
            type: 'input',
            rules: [
              {required: true, validator: validateIp,  trigger: 'blur'}
            ]
          },
          {
            label: '端口号',
            value: '',
            prop: 'port',
            type: 'number',
            rules: [
              {required: true, message: '请输入端口号',  trigger: 'blur'},
              {validator: portRule,  trigger: 'blur'}
            ]
          },
          {
            label: '连接超时时间(秒)',
            value: '',
            prop: 'conTimeout',
            type: 'none', //默认不显示，type设置none，显示时候代码逻辑再设置为number
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '等待连接队列大小',
            value: '',
            prop: 'backlog',
            type: 'none', //默认不显示，type设置none，显示时候代码逻辑再设置为number
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ],
      },
      {
        title: '接包规则配置',
        list: [
          {
            label: '接包规则',
            value: '',
            prop: 'recvRule',
            type: 'select',
            options: 'receive_rule',
            span: 24,
            ruleType: {
              lengthIdentify: {
                title: '字节长度标识',
                list: [
                  {
                    label: '报文最大长度',
                    value: '',
                    prop: 'maxFrameLength',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入报文最大长度',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                  {
                    label: '长度的数据起始位置',
                    value: '',
                    prop: 'lengthFieldOffset',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入长度的数据起始位置',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                  {
                    label: '报文数据长度的字段长度',
                    value: '',
                    prop: 'lengthFieldLength',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入报文数据长度的字段长度',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                  {
                    label: '内容调整长度',
                    value: '',
                    prop: 'lengthAdjustment',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入内容调整长度',  trigger: 'blur'},
                    ]
                  },
                  {
                    label: '跳过字节数',
                    value: '',
                    prop: 'initialBytesToStrip',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入跳过字节数',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                ]
              },
              lengthByString: {
                title: '字符串长度标识',
                list: [
                  {
                    label: '报文最大长度',
                    value: '',
                    prop: 'maxFrameLength',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入报文最大长度',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                  {
                    label: '长度的数据起始位置',
                    value: '',
                    prop: 'lengthFieldOffset',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入长度的数据起始位置',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                  {
                    label: '报文数据长度的字段长度',
                    value: '',
                    prop: 'lengthFieldLength',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入报文数据长度的字段长度',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                  {
                    label: '内容调整长度',
                    value: '',
                    prop: 'lengthAdjustment',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入内容调整长度',  trigger: 'blur'},
                    ]
                  },
                  {
                    label: '跳过字节数',
                    value: '',
                    prop: 'initialBytesToStrip',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入跳过字节数',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                ]
              },
              fixLength: {
                title: '定长报文',
                list: [
                  {
                    label: '定长报文总长度',
                    value: '',
                    prop: 'len',
                    type: 'number',
                    rules: [
                      {required: true, message: '请输入定长报文总长度',  trigger: 'blur'},
                      { validator: integerRule, trigger: 'blur'}
                    ]
                  },
                ]
              },
              endChar: {
                title: '结束符',
                list: [
                  {
                    label: '结束符',
                    value: '',
                    prop: 'endChar',
                    type: 'input',
                    rules: [
                      {required: true, message: '请输入结束符',  trigger: 'blur'}
                    ]
                  },
                ]
              }
            },
          },

        ]
      },
      {
        title: '心路规则配置',
        type: 'none',
        list: [
          {
            label: '心跳时间间隔(秒)',
            prop: 'interval',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '心跳包内容串',
            prop: 'content',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      }
    ],

    jms: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '实现类型',
            value: 'ACTIVE_MQ',
            prop: 'jmsType',
            type: 'select',
            options: 'achieve_type',
            rules: [
              {required: true, message: '请选择实现类型',  trigger: "change"}
            ]
          },
          {
            label: '连接类型',
            value: 'queue',
            prop: 'connetionType',
            type: 'select',
            optionData: [
              {
                label: '队列通讯',
                value: 'queue'
              }
            ]
          },
          {
            label: '连接url',
            value: '',
            prop: 'url',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入连接url',  trigger: 'blur'}
            ]
          },
          {
            label: '持久化',
            value: '2',
            prop: 'persistent',
            type: 'select',
            optionData: [
              {
                label: '是',
                value: '2'
              },
              {
                label: '否',
                value: '1'
              }
            ]
          },
          {
            label: '发送队列',
            value: '',
            prop: 'sendDest',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '接收队列',
            value: '',
            prop: 'receiveDest',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入接收队列',  trigger: 'blur'}
            ]
          },
          {
            label: '文件目录',
            value: '',
            prop: 'fileDir',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '消费者连接数',
            value: '',
            prop: 'consumers',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ],
      }
    ],

    mq: [
      {
        title: '基础配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: 'ip地址',
            value: '',
            prop: 'ip',
            type: 'input',
            rules: [
              {required: true, validator: validateIp,  trigger: 'blur'}
            ]
          },
          {
            label: '端口号',
            value: '',
            prop: 'port',
            type: 'number',
            rules: [
              {required: true, message: '请输入端口号',  trigger: 'blur'},
              {validator: portRule,  trigger: 'blur'}
            ]
          },
          {
            label: '通道名称',
            value: '',
            prop: 'channel',
            type: 'input',
            maxlength: 200,
            rules: [
              {required: true, message: '请输入通道名称',  trigger: 'blur'}
            ]
          },
          {
            label: '队列管理器名称',
            value: '',
            prop: 'queueManager',
            type: 'input',
            maxlength: 200,
            rules: [
              {required: true, message: '请输入队列管理器',  trigger: 'blur'}
            ]
          },
          {
            label: '发送队列',
            value: '',
            prop: 'sendQueueName',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '接收队列',
            value: '',
            prop: 'receiveQueueName',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入接收队列',  trigger: 'blur'}
            ]
          },
          {
            label: '接收超时时间(秒)',
            value: '',
            prop: 'receiveTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '消息周期(秒)',
            value: '',
            prop: 'msgTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '最大连接',
            value: '',
            prop: 'maxConnections',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: 'CCSID',
            value: '',
            prop: 'ccsid',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ],
        obj: {}
      },

    ],

    tlq: [
      {
        title: '基础配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: 'ip地址',
            value: '',
            prop: 'ip',
            type: 'input',
            rules: [
              {required: true, validator: validateIp,  trigger: 'blur'}
            ]
          },
          {
            label: '端口号',
            value: '',
            prop: 'port',
            type: 'number',
            rules: [
              {required: true, message: '请输入端口号',  trigger: 'blur'},
              {validator: portRule,  trigger: 'blur'}
            ]
          },
          {
            label: '队列管理器',
            value: '',
            prop: 'qcuName',
            type: 'input',
            maxlength: 200,
            rules: [
              {required: true, message: '请输入队列管理器',  trigger: 'blur'},
            ]
          },
          {
            label: '消息类型',
            value: '1',
            prop: 'msgType',
            type: 'select',
            options: 'msg_type'
          },
          {
            label: '文件目录',
            value: '',
            prop: 'fileDir',
            type: 'input',
          },
          {
            label: '优先级',
            value: '',
            prop: 'priority',
            type: 'input',
          },
          {
            label: '传送方式',
            value: '0',
            prop: 'encryptOrComp',
            type: 'select',
            options: 'send_way'
          },
          {
            label: '使用事物',
            value: '1',
            prop: 'transaction',
            type: 'select',
            optionData: [
              {
                label: '是',
                value: '1'
              },
              {
                label: '否',
                value: '0'
              }
            ]
          },
          {
            label: '消息最大长度',
            value: '',
            prop: 'msgLength',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '连接方式',
            value: 'C',
            prop: 'mode',
            type: 'select',
            options: 'connect_way'
          },
          {
            label: '发送队列',
            value: '',
            prop: 'sendQueueName',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '文件发送后删除',
            value: '0',
            prop: 'sendFileRemove',
            type: 'select',
            optionData: [
              {
                label: '不删除',
                value: '0'
              },
              {
                label: '删除',
                value: '1'
              }
            ]
          },
          {
            label: '消息周期(秒)',
            value: '',
            prop: 'msgTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '接收队列',
            value: '',
            prop: 'receiveQueueName',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入接收队列',  trigger: 'blur'}
            ]
          },
          {
            label: '接收超时时间(秒)',
            value: '',
            prop: 'receiveTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      }
    ],

    http: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '解码类型',
            value: ' ',
            prop: 'decodeType',
            type: 'select',
            optionData: [
              {
                label: '不解码',
                value: ' '
              },
              {
                label: 'URL解码',
                value: 'url'
              }
            ]
          },
          {
            label: '服务地址',
            value: '',
            prop: 'address',
            type: 'input',
            rules: [
              {required: true, message: '请输入服务地址',  trigger: 'blur'}
            ]
          },
          {
            label: '空闲连接超时时间(秒)',
            value: '',
            prop: 'conTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '等待连接队列大小',
            value: '',
            prop: 'backlog',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      },
      {
        title: 'HTTP头配置',
        type: 'custom',
        list: [
          {
            label: 'HTTP头配置',
            value: [],
            prop: 'entry',
          },
        ]
      }
    ],

    https: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '解码类型',
            value: ' ',
            prop: 'decodeType',
            type: 'select',
            optionData: [
              {
                label: '不解码',
                value: ' '
              },
              {
                label: 'URL解码',
                value: 'url'
              }
            ]
          },
          {
            label: '服务地址',
            value: '',
            prop: 'address',
            type: 'input',
            rules: [
              {required: true, message: '请输入服务地址',  trigger: 'blur'}
            ]
          },
          {
            label: '证书文件',
            value: '',
            prop: 'keystore',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入证书文件',  trigger: 'blur'}
            ]
          },
          {
            label: '证书密码',
            value: '',
            prop: 'keypassword',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入证书密码',  trigger: 'blur'}
            ]
          },
          {
            label: '空闲连接超时时间(秒)',
            value: '',
            prop: 'conTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '等待连接队列大小',
            value: '',
            prop: 'backlog',
            type: 'input',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      },
      {
        title: 'HTTP头配置',
        type: 'custom',
        list: [
          {
            label: 'HTTP头配置',
            value: [],
            prop: 'entry',
          },
        ]
      }
    ],

    ws: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '服务地址',
            value: '',
            prop: 'address',
            type: 'input',
            rules: [
              {required: true, message: '请输入服务地址',  trigger: 'blur'}
            ]
          },
          {
            label: '服务类名',
            value: '',
            prop: 'dealclass',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入服务类名',  trigger: 'blur'}
            ]
          },
        ]
      }
    ],

    custom: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '服务类名',
            value: '',
            prop: 'exterClass',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入服务类名',  trigger: 'blur'}
            ]
          },
        ]
      },
      {
        title: '自定义属性',
        type: 'custom',
        list: [
          {
            label: 'HTTP头配置',
            value: [],
            prop: 'entry',
          },
        ]
      }
    ],
  },

  OUT: {
    tcp: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '连接类型',
            value: 'short',
            prop: 'connetionType',
            type: 'select',
            options: 'connect_type',
            rules: [
              {required: true, message: '请选择连接类型', trigger: 'change'}
            ]
          },
          {
            label: 'ip地址',
            value: '',
            prop: 'ip',
            type: 'input',
            rules: [
              {required: true, validator: validateIp,  trigger: 'blur'}
            ]
          },
          {
            label: '端口号',
            value: '',
            prop: 'port',
            type: 'number',
            rules: [
              {required: true, message: '请输入端口号',  trigger: 'blur'},
              {validator: portRule,  trigger: 'blur'}
            ]
          },
          {
            label: '连接超时时间(秒)',
            value: '',
            prop: 'conTimeout',
            type: 'number',
          },
          {
            label: '等待连接队列大小',
            value: '',
            prop: 'backlog',
            type: 'none', //默认不显示，type设置none，显示时候代码逻辑再设置为number
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '缓冲队列大小',
            value: '',
            prop: 'capacity',
            type: 'number',
            rules: [
              {required: true, message: '请输入缓冲队列大小',  trigger: 'blur'},
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '空闲线程存活时间',
            value: '',
            prop: 'aliveTime',
            type: 'number',rules: [
              {required: true, message: '请输入空闲线程存活时间',  trigger: 'blur'},
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ],
      },
      {
        title: '接包规则配置',
        list: [
          {
            label: '接包规则',
            value: '',
            prop: 'recvRule',
            type: 'select',
            options: 'receive_rule',
            span: 24,
          },
        ]
      },
      {
        title: '心路规则配置',
        type: 'none',
        list: [
          {
            label: '心跳时间间隔(秒)',
            prop: 'interval',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '心跳包内容串',
            prop: 'content',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      }
    ],

    jms: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '实现类型',
            value: 'ACTIVE_MQ',
            prop: 'jmsType',
            type: 'select',
            options: 'achieve_type',
            rules: [
              {required: true, message: '请选择实现类型',  trigger: "change"}
            ]
          },
          {
            label: '连接类型',
            value: 'queue',
            prop: 'connetionType',
            type: 'select',
            optionData: [
              {
                label: '队列通讯',
                value: 'queue'
              }
            ]
          },
          {
            label: '连接url',
            value: '',
            prop: 'url',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入连接url',  trigger: 'blur'}
            ]
          },
          {
            label: '持久化',
            value: '2',
            prop: 'persistent',
            type: 'select',
            optionData: [
              {
                label: '是',
                value: '2'
              },
              {
                label: '否',
                value: '1'
              }
            ]
          },
          {
            label: '发送队列',
            value: '',
            prop: 'sendDest',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入发送队列',  trigger: 'blur'}
            ]
          },
          {
            label: '接收队列',
            value: '',
            prop: 'receiveDest',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '文件目录',
            value: '',
            prop: 'fileDir',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '接收超时时间(秒)',
            value: '',
            prop: 'receiveTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '消息周期(秒)',
            value: '',
            prop: 'msgTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '最大连接',
            value: '',
            prop: 'maxConnections',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '会话数',
            value: '',
            prop: 'maxSessions',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ],
      }
    ],

    mq: [
      {
        title: '基础配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: 'ip地址',
            value: '',
            prop: 'ip',
            type: 'input',
            rules: [
              {required: true, validator: validateIp,  trigger: 'blur'}
            ]
          },
          {
            label: '端口号',
            value: '',
            prop: 'port',
            type: 'number',
            rules: [
              {required: true, message: '请输入端口号',  trigger: 'blur'},
              {validator: portRule,  trigger: 'blur'}
            ]
          },
          {
            label: '通道名称',
            value: '',
            prop: 'channel',
            type: 'input',
            maxlength: 200,
            rules: [
              {required: true, message: '请输入通道名称',  trigger: 'blur'}
            ]
          },
          {
            label: '队列管理器名称',
            value: '',
            prop: 'queueManager',
            type: 'input',
            maxlength: 200,
            rules: [
              {required: true, message: '请输入队列管理器',  trigger: 'blur'}
            ]
          },
          {
            label: '发送队列',
            value: '',
            prop: 'sendQueueName',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入发送队列',  trigger: 'blur'}
            ]
          },
          {
            label: '接收队列',
            value: '',
            prop: 'receiveQueueName',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '接收超时时间(秒)',
            value: '',
            prop: 'receiveTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '消息周期(秒)',
            value: '',
            prop: 'msgTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '最大连接',
            value: '',
            prop: 'maxConnections',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: 'CCSID',
            value: '',
            prop: 'ccsid',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ],
        obj: {}
      },

    ],

    tlq: [
      {
        title: '基础配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: 'ip地址',
            value: '',
            prop: 'ip',
            type: 'input',
            rules: [
              {required: true, validator: validateIp,  trigger: 'blur'}
            ]
          },
          {
            label: '端口号',
            value: '',
            prop: 'port',
            type: 'number',
            rules: [
              {required: true, message: '请输入端口号',  trigger: 'blur'},
              {validator: portRule,  trigger: 'blur'}
            ]
          },
          {
            label: '队列管理器',
            value: '',
            prop: 'qcuName',
            type: 'input',
            maxlength: 200,
            rules: [
              {required: true, message: '请输入队列管理器',  trigger: 'blur'},
            ]
          },
          {
            label: '消息类型',
            value: '1',
            prop: 'msgType',
            type: 'select',
            options: 'msg_type'
          },
          {
            label: '文件目录',
            value: '',
            prop: 'fileDir',
            type: 'input',
            maxlength: 200,
          },
          {
            label: '优先级',
            value: '',
            prop: 'priority',
            type: 'input',
          },
          {
            label: '传送方式',
            value: '0',
            prop: 'encryptOrComp',
            type: 'select',
            options: 'send_way'
          },
          {
            label: '使用事物',
            value: '1',
            prop: 'transaction',
            type: 'select',
            optionData: [
              {
                label: '是',
                value: '1'
              },
              {
                label: '否',
                value: '0'
              }
            ]
          },
          {
            label: '消息最大长度',
            value: '',
            prop: 'msgLength',
            type: 'input',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '连接方式',
            value: 'C',
            prop: 'mode',
            type: 'select',
            options: 'connect_way'
          },
          {
            label: '发送队列',
            value: '',
            prop: 'sendQueueName',
            type: 'input',
            maxlength: 300,
            rules: [
              {required: true, message: '请输入发送队列',  trigger: 'blur'},
            ]
          },
          {
            label: '文件发送后删除',
            value: '0',
            prop: 'sendFileRemove',
            type: 'select',
            optionData: [
              {
                label: '不删除',
                value: '0'
              },
              {
                label: '删除',
                value: '1'
              }
            ]
          },
          {
            label: '消息周期(秒)',
            value: '',
            prop: 'msgTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '接收队列',
            value: '',
            prop: 'receiveQueueName',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '接收超时时间(秒)',
            value: '',
            prop: 'receiveTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      }
    ],

    http: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '解码类型',
            value: ' ',
            prop: 'decodeType',
            type: 'select',
            optionData: [
              {
                label: '不解码',
                value: ' '
              },
              {
                label: 'URL解码',
                value: 'url'
              }
            ]
          },
          {
            label: '服务地址',
            value: '',
            prop: 'address',
            type: 'input',
            rules: [
              {required: true, message: '请输入服务地址',  trigger: 'blur'}
            ]
          },
          {
            label: '空闲连接超时时间(秒)',
            value: '',
            prop: 'conTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '连接池最大连接数',
            value: '',
            prop: 'maxConCount',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      },
      {
        title: 'HTTP头配置',
        type: 'custom',
        list: [
          {
            label: 'HTTP头配置',
            value: [],
            prop: 'entry',
          },
        ]
      }
    ],

    https: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '解码类型',
            value: ' ',
            prop: 'decodeType',
            type: 'select',
            optionData: [
              {
                label: '不解码',
                value: ' '
              },
              {
                label: 'URL解码',
                value: 'url'
              }
            ]
          },
          {
            label: '服务地址',
            value: '',
            prop: 'address',
            type: 'input',
            rules: [
              {required: true, message: '请输入服务地址',  trigger: 'blur'}
            ]
          },
          {
            label: '连接超时时间(秒)',
            value: '',
            prop: 'conTimeout',
            type: 'number',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
          {
            label: '连接池最大连接数',
            value: '',
            prop: 'maxConCount',
            type: 'input',
            rules: [
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      },
      {
        title: 'HTTP头配置',
        type: 'custom',
        list: [
          {
            label: 'HTTP头配置',
            value: [],
            prop: 'entry',
          },
        ]
      }
    ],

    ws: [
      {
        title: '基本配置',
        list: [
          {
            label: '字符集编码',
            value: 'UTF-8',
            prop: 'charset',
            type: 'select',
            options: 'charset_type',
            rules: [
              {required: true, message: '请选择字符集编码', trigger: 'change'}
            ]
          },
          {
            label: '是否启用',
            value: 'true',
            prop: 'enable',
            type: 'select',
            options: 'whether_status',
            rules: [
              {required: true, message: '请选择是否启用', trigger: 'change'}
            ]
          },
          {
            label: '服务地址',
            value: '',
            prop: 'address',
            type: 'input',
            rules: [
              {required: true, message: '请输入服务地址',  trigger: 'blur'}
            ]
          },
          {
            label: '接口列表',
            value: '',
            prop: 'dealclass',
            type: 'input',
            maxlength: 300,
          },
          {
            label: '连接超时(秒)',
            value: '',
            prop: 'connTimeOut',
            type: 'number',
            rules: [
              {required: true, message: '请输入连接超时时间',  trigger: 'blur'},
              { validator: rule.validatorNumber, trigger: 'blur'}
            ]
          },
        ]
      }
    ],

  }
}
//接入类型都有的配置
Object.values(formData.IN).forEach(item => {
  item.splice(1, 0, threadPool)
})
//接出类型除了ws外都有的配置
for (let [key, value] of Object.entries(formData.OUT)) {
  if (key !== 'ws') value.splice(1, 0, thirdPlu)
}
formData.IN.tlq.push(thirdPlu)


export const recvRule = {
  lengthIdentify: {
    title: '字节长度标识',
    list: [
      {
        label: '报文最大长度',
        value: '',
        prop: 'maxFrameLength',
        type: 'number',
        rules: [
          {required: true, message: '请输入报文最大长度',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
      {
        label: '长度的数据起始位置',
        value: '',
        prop: 'lengthFieldOffset',
        type: 'number',
        rules: [
          {required: true, message: '请输入长度的数据起始位置',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
      {
        label: '报文数据长度的字段长度',
        value: '',
        prop: 'lengthFieldLength',
        type: 'number',
        rules: [
          {required: true, message: '请输入报文数据长度的字段长度',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
      {
        label: '内容调整长度',
        value: '',
        prop: 'lengthAdjustment',
        type: 'number',
        rules: [
          {required: true, message: '请输入内容调整长度',  trigger: 'blur'},
        ]
      },
      {
        label: '跳过字节数',
        value: '',
        prop: 'initialBytesToStrip',
        type: 'number',
        rules: [
          {required: true, message: '请输入跳过字节数',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
    ]
  },
  lengthByString: {
    title: '字符串长度标识',
    list: [
      {
        label: '报文最大长度',
        value: '',
        prop: 'maxFrameLength',
        type: 'number',
        rules: [
          {required: true, message: '请输入报文最大长度',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
      {
        label: '长度的数据起始位置',
        value: '',
        prop: 'lengthFieldOffset',
        type: 'number',
        rules: [
          {required: true, message: '请输入长度的数据起始位置',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
      {
        label: '报文数据长度的字段长度',
        value: '',
        prop: 'lengthFieldLength',
        type: 'number',
        rules: [
          {required: true, message: '请输入报文数据长度的字段长度',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
      {
        label: '内容调整长度',
        value: '',
        prop: 'lengthAdjustment',
        type: 'number',
        rules: [
          {required: true, message: '请输入内容调整长度',  trigger: 'blur'},
        ]
      },
      {
        label: '跳过字节数',
        value: '',
        prop: 'initialBytesToStrip',
        type: 'number',
        rules: [
          {required: true, message: '请输入跳过字节数',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
    ]
  },
  fixLength: {
    title: '定长报文',
    list: [
      {
        label: '定长报文总长度',
        value: '',
        prop: 'len',
        type: 'number',
        rules: [
          {required: true, message: '请输入定长报文总长度',  trigger: 'blur'},
          { validator: integerRule, trigger: 'blur'}
        ]
      },
    ]
  },
  endChar: {
    title: '结束符',
    list: [
      {
        label: '结束符',
        value: '',
        prop: 'endChar',
        type: 'input',
        rules: [
          {required: true, message: '请输入结束符',  trigger: 'blur'},
        ]
      },
    ]
  }
}

export const typeConfig = [
  {
    label: '通讯协议',
    value: '',
    prop: 'type',
    type: 'select',
    options: 'protocol_type'
  },
  {
    label: '接入接出类型',
    value: '',
    prop: 'commType',
    type: 'select',
    options: 'comm_type'
  },
]

export const typeChange = {
  IN: [
    {
      label: '系统名称',
      value: '',
      prop: 'sysCode',
      type: 'select',
      options: '',
      optionData: [],
    },
    {
      label: '系统分组',
      value: '',
      prop: 'groupCode',
      type: 'select',
      options: '',
      optionData: [],
    },
  ],
  OUT: [
    {
      label: '接出名称',
      value: '',
      prop: 'sysCode',
      type: 'select',
      options: '',
      optionData: [],
    },
  ]
}

export default formData
